package com.itstudio.myforumsystem.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itstudio.myforumsystem.entity.Article;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Service;

import java.util.List;

@Mapper
public interface ArticleMapper extends BaseMapper<Article> {

    @Update("update article set readnumber =readnumber+1 where id=#{id}")
    void updateReadNum(Integer id);
@Select("select a.* from article a left join sys_user u on a.userid=u.id where u.id=#{id}")
   List<Article> findUsersArticleBynickname(Integer id);
@Select("select * from article order by readnumber desc limit 5")
    List<Article> selectRecommandArticleLimitFive();
@Select("select a.* from collection c left join article a on c.articleid=a.id where a.userid=#{userid}")
    List<Article> selectCollectionArticle(Integer userid);
}
